package com.user.config.sa;

import cn.dev33.satoken.stp.StpInterface;
import com.user.service.IRole;
import com.user.service.IRoleMenu;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;

/**
 * @program: Member_Perks_Store
 * @description: 个人权限
 * @author: 无恙
 * @create: 2024-06-16 21:52
 **/

@Component
public class StpInterfaceImpl implements StpInterface {

    @Resource
    private IRole Irole;

    @Resource
    private IRoleMenu IRoleMenu;
    /**
     * 返回一个账号所拥有的权限码集合
     */
    @Override
    public List<String> getPermissionList(Object loginId, String loginType) {

        return IRoleMenu.getPermissionByUid(Long.parseLong(loginId.toString()));
    }

    /**
     * 返回一个账号所拥有的角色标识集合 (权限与角色可分开校验)
     */
    @Override
    public List<String> getRoleList(Object loginId, String loginType) {
        return Irole.getRoleIdByUid(Long.parseLong(loginId.toString()));
    }
}
